package net.apexes.demo.codegen.ormlite.column;

import net.apexes.commons.ormlite.Column;
import net.apexes.commons.ormlite.ForeignKey;
import net.apexes.commons.ormlite.Index;
import net.apexes.demo.codegen.ormlite.column.base.QEntityBase;
import net.apexes.demo.codegen.ormlite.entity.GoodsComboItem;

/**
 * QGoodsComboItem is a ORMLite query type for GoodsComboItem
 * @see GoodsComboItem
 */
public class QGoodsComboItem extends QEntityBase<GoodsComboItem> {

    public static final QGoodsComboItem $ = new QGoodsComboItem("GOODS_COMBO_ITEM");

    public final Column goodsComboGroupId = field("goodsComboGroupId").columnName("GOODS_COMBO_GROUP_ID").varchar(22).notNull().build();

    public final Column parentGoodsId = field("parentGoodsId").columnName("PARENT_GOODS_ID").varchar(22).notNull().build();

    public final Column childGoodsId = field("childGoodsId").columnName("CHILD_GOODS_ID").varchar(22).notNull().build();

    public final Column price = field("price").columnName("PRICE").decimal(12, 3).notNull().build();

    public final Column templateId = field("templateId").columnName("TEMPLATE_ID").varchar(22).notNull().build();

    public class Indexs {

        public final Index constraintIndex36 = index("CONSTRAINT_INDEX_36").column(childGoodsId).build();

        public final Index constraintIndex367 = index("CONSTRAINT_INDEX_367").column(parentGoodsId).build();

        public final Index constraintIndex3678 = index("CONSTRAINT_INDEX_3678").column(goodsComboGroupId).build();

        public final Index primaryKey36 = index("PRIMARY_KEY_36").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraint367 = foreignKey(childGoodsId, "GOODS", "ID");

        public final ForeignKey constraint3678 = foreignKey(parentGoodsId, "GOODS", "ID");

        public final ForeignKey constraint3678d = foreignKey(goodsComboGroupId, "GOODS_COMBO_ITEM_GROUP", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QGoodsComboItem(String tableName) {
        super(GoodsComboItem.class, tableName);
    }

    @Override
    public GoodsComboItem newInstance() {
        return new GoodsComboItem();
    }

    @Override
    public Object getFieldValue(GoodsComboItem instance, String fieldName) {
        switch (fieldName) {
            case "goodsComboGroupId":
                return instance.getGoodsComboGroupId();
            case "parentGoodsId":
                return instance.getParentGoodsId();
            case "childGoodsId":
                return instance.getChildGoodsId();
            case "price":
                return instance.getPrice();
            case "templateId":
                return instance.getTemplateId();
            default:
                return super.getFieldValue(instance, fieldName);
        }
    }

    @Override
    public void setupFieldValue(GoodsComboItem instance, String fieldName, Object value) {
        switch (fieldName) {
            case "goodsComboGroupId":
                instance.setGoodsComboGroupId((java.lang.String) value);
                break;
            case "parentGoodsId":
                instance.setParentGoodsId((java.lang.String) value);
                break;
            case "childGoodsId":
                instance.setChildGoodsId((java.lang.String) value);
                break;
            case "price":
                instance.setPrice((java.math.BigDecimal) value);
                break;
            case "templateId":
                instance.setTemplateId((java.lang.String) value);
                break;
            default:
                super.setupFieldValue(instance, fieldName, value);
                break;
        }
    }

}

